package com.hengpeng.itfin.tools;

import java.util.Collection;
import java.util.Random;

/**
 * <pre>
 * 计算工具类
 * </pre>
 * 
 * @author chenjian
 * @version 1.0, 2011-8-20
 */
public class Tools {
    public static boolean validateObjectsNullOrEmpty(Object... obj) {
        if (obj == null)
            return true;
        for (Object o : obj) {
            boolean isEmpty;
            if (o instanceof String) {
                isEmpty = o.toString().trim().equals("");
            } else if (o instanceof Collection<?>) {
                Collection<?> list = (Collection<?>) o;
                isEmpty = list.size() == 0;
            } else {
                isEmpty = (o == null);
            }
            if (isEmpty)
                return true;
        }
        return false;
    }

    /**
     * 获取指定范围随机数
     * 
     * @param max_ext
     * @param min_ext
     * @return
     */
    public static int getRandom(int max_ext, int min_ext) {
        Random random = new Random();
        int s = random.nextInt(max_ext) % (max_ext - min_ext + 1) + min_ext;
        return s;
    }
}
